<!DOCTYPE html>
<html>
	<head>
<title>订单查询</title>
	<!-- jQuery 主文件 -->
	<script type="text/javascript" src="../js/jquery.min.js" ></script>
	<!-- easyui 主文件 -->
	<script type="text/javascript" src="../js/jquery.easyui.min.js" ></script>
	<!-- 国际化文件 -->
	<script type="text/javascript" src="../js/locale/easyui-lang-zh_CN.js" ></script>
	<!-- easyui 主样式文件 -->
	<link rel="stylesheet" href="../js/themes/black/easyui.css" />
	<link rel="stylesheet" href="../js/themes/icon.css" />	
	<script type="text/javascript">
	$(function(){ 
		$("#btnSearch").click(function () {  
	        var pars = {starttime:$('#starttime').datebox('getValue'),endtime:$('#endtime').datebox('getValue')};  
	        //有参数时执行此方法  
	        initTable(pars);  
	    });  
	    //无参数时执行此方法  
	    initTable("");  
	})
	function initTable(pars){
		$("#tb").datagrid({
		   	url:"purchaselist2",
		   	method:"get",
		   	queryParams:pars,
			columns:[[  
	            {field:'Id',title:'全选',width:100,checkbox:true},      
		        {field:'purchaseId',title:'订单号',width:100,align:'right'},    
		        {field:'productId',title:'产品编号',width:100,align:'right'},    
		        {field:'productName',title:'产品名称',width:100,align:'right'}, 
		        {field:'productType',title:'产品类型',width:100,align:'right'},
				{field:'productNumber',title:'产品数量',width:100,align:'right'},
				{field:'productPieces',title:'单位 ',width:100,align:'right'}, 
				{field:'productPrices',title:'单价(元)',width:100,align:'right'}, 
				{field:'purchaser',title:'采购员',width:100,align:'right'}, 
				{field:'purchasedate',title:'采购时间',width:100,align:'right'},
				{field:'dealine',title:'到货时间 ',width:100,align:'right'},
				{field:'purchaseLister',title:'审批人',width:100,align:'right'},
				{field:'remark',title:'备注 ',width:100,align:'right'},
				{field:'supplierId',title:'供货商编号 ',width:100,align:'right'},
		    ]],
		    fit:true,
		    toolbar: '#query',
			loadMsg:"数据加载中...，请等待!",
			pageSize:10,
			singleSelect:true,
			fitColumns:true,
			pagination:true,
			rownumbers:true,
			onClickRow:function(rowIndex, rowData){
//								alert(rowIndex);
//				alert(rowData.productName);
			}
	});
	}	
		function print(){
			var row = $('#tb').datagrid('getSelected');	
			if (row&&row.remark=="未下单"){
				if(confirm("确定下单？")){
				location="pdf?purchaseId="+row.purchaseId;
				$('#tb').datagrid('reload');
				}
			}else{
				alert("该产品已下单");
			}
			
		}
	</script>
	<style type="text/css">
		#fm{
			margin:0;
			padding:10px 30px;
		}
		.ftitle{
			font-size:14px;
			font-weight:bold;
			color:#666;
			padding:5px 0;
			margin-bottom:10px;
			border-bottom:1px solid #ccc;
		}
		.fitem{
			margin-bottom:5px;
		}
		.fitem label{
			display:inline-block;
			width:80px;
		}
	</style>
	</head>
	<body>
		<div id="query" >
			&nbsp;&nbsp;&nbsp;<span style="color:white;font-size:13px;font-weight:bold">起始时间</span>&nbsp;&nbsp;<input  id="starttime" name="starttime" type= "text" class= "easyui-datebox" style="margin-left:200px"></input>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
			<span style="color:white;font-size:13px;font-weight:bold">终止时间</span>&nbsp;&nbsp;<input  id="endtime" name="endtime" type= "text" class= "easyui-datebox"></input> 
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<a id="btnSearch" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls: 'icon-query'">查询</a>
			<a id="btn" href="javascript:print()" class="easyui-linkbutton" data-options="iconCls: 'icon-print'">打印</a>
		</div>

		<table id="tb" title="订单查询表"></table>

	</body>
</html>
